{extend name="index/iframe" /}

{block name="content"}
<form class="layui-form" action="" style="padding-top:10px; padding-right:10px;">
    <input type="hidden" value="{$Think.get.game_id}" name="game_id">
    <div class="layui-form-item">
        <div class="layui-row">
            <div class="layui-col-xs3">
                <label class="layui-form-label">游戏版本</label>
                <div class="layui-input-block">
                    <select name="app_server_id" disabled lay-filter="app_server_id" id="app_server_id" lay-verify="required" lay-search="">
                        <option value="">部门 - 版本 - 游戏名</option>
                        {volist name="app_server_id" id="vo"}
                        <option value="{$vo.id}" {$vo.id==$find.app_server_id ? 'selected' : ''}>{$vo.app_type_name} - {$vo.app_publish_type_name} - {$vo.game_name}</option>
                        {/volist}
                    </select>
                </div>
            </div>
            <div class="layui-col-xs3">
                <label class="layui-form-label">游戏平台</label>
                <div class="layui-input-block">
                    <select name="app_platform_type_id" lay-filter="app_platform_type_id" id="app_platform_type_id" lay-verify="required">
                        <option value="">请选择游戏平台</option>
                        {volist name="$app_platform_type_id" id="vo"}
                        <option value="{$vo.id}" {$vo.id==$find.app_platform_type_id ? 'selected' : ''}>{$vo.name}</option>
                        {/volist}
                    </select>
                </div>
            </div>
            <div class="layui-col-xs3">
                <label class="layui-form-label">游戏终端</label>
                <div class="layui-input-block">
                    <select name="app_client_type_id" lay-filter="app_client_type_id" id="app_client_type_id" lay-verify="required">
                        <option value="">请选择游戏终端</option>
                        {volist name="$app_client_type_id" id="vo"}
                        <option value="{$vo.id}" {$vo.id==$find.app_client_type_id ? 'selected' : ''}>{$vo.name}</option>
                        {/volist}
                    </select>
                </div>
            </div>
            <div class="layui-col-xs3">
                <label class="layui-form-label">游戏名称</label>
                <div class="layui-input-block">
                    <input type="text" name="game_name" value="{$find.game_name}" id="game_name" placeholder="请输入游戏名称" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-row">
            <div class="layui-col-xs3">
                <label class="layui-form-label">上传位置</label>
                <div class="layui-input-block">
                    <select name="up_location" lay-filter="up_location" id="up_location" lay-verify="required">
                        <option value="">上传位置</option>
                        <option value="0" {if condition="$find.up_location eq 0"}selected{/if}>CDN</option>
                        <option value="1" {if condition="$find.up_location eq 1"}selected{/if}>金山云</option>
                    </select>
                </div>
            </div>
            <div class="layui-col-xs3">
                <label class="layui-form-label">SDK版本</label>
                <div class="layui-input-block">
                    <select name="sdk_version" lay-filter="sdk_version" id="sdk_version" lay-verify="required">
                        <option value="">SDK版本</option>
                        <option value="v1.0" {$find.sdk_version=='v1.0' ? 'selected' : ''}>v1.0</option>
                        <option value="v2.0" {$find.sdk_version=='v2.0' ? 'selected' : ''}>v2.0</option>
                    </select>
                </div>
            </div>
            <div class="layui-col-xs3">
                <label class="layui-form-label">H5游戏地址</label>
                <div class="layui-input-block">
                    <input type="text" name="h5_game_url" value="{$find.h5_game_url}" id="h5_game_url" placeholder="请输入H5游戏地址" autocomplete="off" class="layui-input layui-disabled" disabled>
                </div>
            </div>
            <div class="layui-col-xs3">
                <label class="layui-form-label">支付回调</label>
                <div class="layui-input-block">
                    <input type="text" name="pay_callback" value="{$find.pay_callback}" id="pay_callback" placeholder="请输入支付回调地址" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-row">
            <div class="layui-col-xs3">
                <label class="layui-form-label">返利回调</label>
                <div class="layui-input-block">
                    <input type="text" name="rebate_callback" value="{$find.rebate_callback}" id="rebate_callback" placeholder="请输入返利回调" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-col-xs3">
                <label class="layui-form-label">GM回调</label>
                <div class="layui-input-block">
                    <input type="text" name="gm_callback" value="{$find.gm_callback}" id="gm_callback" placeholder="请输入GM回调" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-col-xs3">
                <label class="layui-form-label">游戏秘钥</label>
                <div class="layui-input-block">
                    <input type="text" name="secret" value="{$find.secret}" id="secret" placeholder="请输入游戏秘钥" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-col-xs3">
                <label class="layui-form-label">苹果支付</label>
                <div class="layui-input-block">
                    <select name="apple_recharge" lay-filter="apple_recharge" id="apple_recharge" lay-verify="required">
                        <option value="">苹果支付</option>
                        <option value="0" {if condition="$find.apple_recharge eq 0"}selected{/if}>关闭</option>
                        <option value="1" {if condition="$find.apple_recharge eq 1"}selected{/if}>开启</option>
                    </select>
                </div>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
            <div class="layui-col-xs3">
                <label class="layui-form-label">苹果浮点</label>
                <div class="layui-input-block">
                    <select name="apple_float" lay-filter="apple_float" id="apple_float" lay-verify="required">
                        <option value="">苹果浮点</option>
                        <option value="0" {if condition="$find.apple_float eq 0"}selected{/if}>关闭</option>
                        <option value="1" {if condition="$find.apple_float eq 1"}selected{/if}>开启</option>
                    </select>
                </div>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-row">
            <div class="layui-col-xs4">
                <label class="layui-form-label">上线日期</label>
                <div class="layui-input-block">
                    <input type="text" name="online_time_region" value="{$find.online_time_region}" class="layui-input datetime-item" lay-verify="datetime" id="online_time_region" placeholder="yyyy-MM-dd HH:mm:ss - yyyy-MM-dd HH:mm:ss" autocomplete="off">
                </div>
            </div>
            <div class="layui-col-xs4">
                <label class="layui-form-label">预发布</label>
                <div class="layui-input-block">
                    <input type="text" name="plat_show_region" value="{$find.plat_show_region}" class="layui-input datetime-item" lay-verify="datetime" id="plat_show_region" placeholder="yyyy-MM-dd HH:mm:ss - yyyy-MM-dd HH:mm:ss"  lay-verify="datetime" autocomplete="off">
                </div>
            </div>
            <div class="layui-col-xs4">
                <label class="layui-form-label">充值开放</label>
                <div class="layui-input-block">
                    <input type="text" name="charge_time_region" value="{$find.charge_time_region}" class="layui-input datetime-item" lay-verify="datetime" id="charge_time_region" placeholder="yyyy-MM-dd HH:mm:ss - yyyy-MM-dd HH:mm:ss"  lay-verify="datetime" autocomplete="off">
                </div>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-row">
            <div class="layui-col-xs4">
                <label class="layui-form-label">注册开放</label>
                <div class="layui-input-block">
                    <input type="text" name="reg_time_region" value="{$find.reg_time_region}" class="layui-input datetime-item" lay-verify="datetime" id="reg_time_region" placeholder="yyyy-MM-dd HH:mm:ss - yyyy-MM-dd HH:mm:ss"  lay-verify="datetime" autocomplete="off">
                </div>
            </div>
            <div class="layui-col-xs4">
                <label class="layui-form-label">登录开放</label>
                <div class="layui-input-block">
                    <input type="text" name="login_time_region" value="{$find.login_time_region}" class="layui-input datetime-item" lay-verify="datetime" id="login_time_region" placeholder="yyyy-MM-dd HH:mm:ss - yyyy-MM-dd HH:mm:ss"  lay-verify="datetime" autocomplete="off">
                </div>
            </div>
            <div class="layui-col-xs4">
                <label class="layui-form-label">打包开放</label>
                <div class="layui-input-block">
                    <input type="text" name="pack_time_region" value="{$find.pack_time_region}" class="layui-input datetime-item" lay-verify="datetime" id="pack_time_region" placeholder="yyyy-MM-dd HH:mm:ss - yyyy-MM-dd HH:mm:ss"  lay-verify="datetime" autocomplete="off">
                </div>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn my-btn" lay-submit="" lay-filter="submitBtn">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
{/block}

{block name="css"}
<style>

    .layui-form-selected dl {z-index:10000;}
</style>
{/block}

{block name="js"}
<script>
    layui.use(['form', 'laydate', 'element', 'upload'], function(){
        var form = layui.form
            ,$ = layui.$
            ,layer = layui.layer
            ,laydate = layui.laydate;

        //同时绑定多个日期
        lay('.datetime-item').each(function(){
            laydate.render({
                elem: this
                ,type: 'datetime'
                ,range: true
                ,calendar: true
                ,min: '2016-01-01'
            });
        });

//        if({$find.app_platform_type_id|default=0}==3){
//            $("#sdk_version").val("v2.0");
//            $('#h5_game_url').removeClass('layui-disabled').attr('disabled', false);
//        }
//        else{
//            $("#sdk_version").val("v1.0");
//            $('#h5_game_url').addClass('layui-disabled').attr('disabled', true);
//        }
        form.render('select');

        form.on('select(app_platform_type_id)', function(data){
            var html0 = '<option value="">请选择游戏终端</option>';
            var html1 = '<option value="1">Android手游</option>';
            var html2 = '<option value="2">iOS商店版</option>';
            var html3 = '<option value="3">iOS越狱版</option>';
            var html4 = '<option value="4">H5直链版</option>';
            var html5 = '<option value="5">Android微端</option>';
            var html6 = '<option value="6">iOS苹果商城微端</option>';
            var html7 = '<option value="7">iOS越狱微端</option>';

            if(data.value==''){
                $('#app_client_type_id').html(html0+html1+html2+html3+html4+html5+html6+html7);
            }
            if(data.value==1){
                $('#app_client_type_id').html(html1+html5);
            }
            if(data.value==2){
                $('#app_client_type_id').html(html2+html3+html6+html7);
            }
            if(data.value==3){
                $('#app_client_type_id').html(html4);

                $("#sdk_version").val("v2.0");
                $('#h5_game_url').removeClass('layui-disabled').attr('disabled', false);
            }else{
                $("#sdk_version").val("v1.0");
                $('#h5_game_url').addClass('layui-disabled').attr('disabled', true);
            }
            form.render('select');
        });

        form.on('select(app_client_type_id)', function(data){
            var html0 = '<option value="">请选择游戏平台</option>';
            var html1 = '<option value="1">Android</option>';
            var html2 = '<option value="2">IOS</option>';
            var html3 = '<option value="3">H5</option>';
            if(data.value==''){
                $('#app_platform_type_id').html(html0+html1+html2+html3);
            }
            if(data.value==1){
                $('#app_platform_type_id').html(html1);
            }
            if(data.value==2){
                $('#app_platform_type_id').html(html2);
            }
            if(data.value==3){
                $('#app_platform_type_id').html(html2);
            }
            if(data.value==4){
                $('#app_platform_type_id').html(html3);
            }
            if(data.value==5){
                $('#app_platform_type_id').html(html1);
                $('#h5_game_url').removeClass('layui-disabled').attr('disabled', false);
            }else{
                $('#h5_game_url').addClass('layui-disabled').attr('disabled', true);
            }
            if(data.value==6){
                $('#app_platform_type_id').html(html2);
            }
            if(data.value==7){
                $('#app_platform_type_id').html(html2);
            }
            form.render('select');
        });


        //提交
        form.on('submit(submitBtn)', function(data){
            var load = layer.load();
            $.post('{:url("GameList/clientEdit")}',data.field, function(json){
                layer.close(load);
                json.code==0 ? layer.msg(json.msg, {icon: 1, time: 1000}) : layer.msg(json.msg, {icon: 0, time: 1000});
            }, 'JSON').error(function(){
                layer.close(load);
                layer.msg('连接超时，请联系后台管理员', {icon: 2, time:3000});
            });
            return false;
        });
    });
</script>
{/block}